-
Notifications
You must be signed in to change notification settings - Fork 13.9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add -i
option to Msf::Ui::Console::CommandDispatcher::Session
mixin's sessions
command
#18885
Conversation
- Fixes spec test for sessions command where session id should be sent as a string and not as an integer
I like that this makes the usage syntax consistent. |
print_line | ||
print_line('Interact with a different session Id.') | ||
print_line('This works the same as calling this from the MSF shell: sessions -i <session id>') | ||
print_line | ||
end | ||
|
||
def cmd_sessions(*args) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Would it make sense to add in a Rex Parser here?:
@@session_opts = Rex::Parser::Arguments.new(
['-h', '--help] => [ false, 'Show this message' ],
['-i', '--interact'] => [ true, 'Interact with a provided session ID' ]
)
@@session_opts.parse(args) do |opt, _idx, val|
case opt
when '-h'
...
when '-i'
...
else
...
end
end
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Since there's only one option needed here, for simplicity's sake I feel we don't need this. If we use this, we'll also have to separately handle sessions <id>
as done here. If there's plans of adding new options here, it'd make sense to use the rex parser. I'll happily add the rex parser if you still feel we should use it.
Yup will add that👍
|
||
it 'backgrounds the session and switches to the new session' do | ||
subject.cmd_sessions(new_session_id) | ||
subject.cmd_sessions('-i', new_session_id) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is there a reason why this test was changed, rather than a new one added for sessions -i <id>
? It seems like now we only test the -i
functionality, with the previous functionality of sessions <id>
not being tested.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Initially I thought since both use the same back-end, a single test would suffice. But now in hindsight, I feel we'd need two separate tests. Will add it👍
Sorry for the late response @sjanusz-r7 had some personal work, I've now made the reviewed changes. |
This is very nice, thank you!
|
This is a bit weird that the validation doesn't happen before attempting to swap sessions, but I believe that's existing behavior so not an issue!
|
Release NotesEnhances the |
@adfoster-r7 Another (small) issue I found while testing this was that when we switch sessions immediately after getting a meterpreter shell, we aren't prompted about the session we are switching into.
It's a minor inconsistency in output, I thought I should mention it somewhere |
Interesting! I wonder why that's happening 🤔 Agreed that it's a minor issue 💯 |
Fixes #18811
This PR adds a
-i
option toMsf::Ui::Console::CommandDispatcher::Session
mixin'ssessions
command. This change would affectmeterpreter
,smb
,sql
consoles.I've also updated the spec tests for the same
Verification
meterpreter
sessions-i
option to interact with different sessions